//贪婪大陆
//https://www.luogu.com.cn/problem/P2184
#include <iostream>
#include <string.h>
using namespace std;

#define lc (p << 1)
#define rc (p << 1 | 1)

const int N = 1e5 + 10;
int n, m;

struct
{
	int l, r;
	int arr[2];
	//arr[0] 表示起点数量
	//arr[1] 表示终点数量
}arr[N << 2];

//维护终点数量
void pushup(int p)
{
	arr[p].arr[0] = arr[lc].arr[0] + arr[rc].arr[0];
	arr[p].arr[1] = arr[lc].arr[1] + arr[rc].arr[1];
}

void build(int p, int l, int r)
{
	arr[p] = { l,r,0,0 };
	if (l == r) return;
	int mid = l + (r - l) / 2;
	//构建左右子树
	build(lc, l, mid); build(rc, mid + 1, r);
	pushup(p);
}

//修改节点信息
void insert(int p, int x, int pos)
{
	int l = arr[p].l, r = arr[p].r;
	if (l == x && r == x)
	{
		arr[p].arr[pos]++;
		return;
	}

	int mid = l + (r - l) / 2;
	if (x <= mid) insert(lc, x, pos);
	else insert(rc, x, pos);
	pushup(p);
}

int find(int p, int x, int y, int pos)
{
	int l = arr[p].l, r = arr[p].r;
	if (x <= l && y >= r) return arr[p].arr[pos];
	int mid = l + (r - l) / 2;
	
	int sum = 0;
	if (x <= mid) sum += find(lc, x, y, pos);
	if (y > mid) sum += find(rc, x, y, pos);
	return sum;
}

int main()
{
	cin >> n >> m;
	build(1, 1, n);
	for (int i = 1; i <= m; i++)
	{
		int q, l, r; cin >> q >> l >> r;
		if (q == 1)
		{
			insert(1, l, 0); insert(1, r, 1);
		}
		else
		{
			cout << find(1, 1, r, 0) - find(1, 1, l - 1, 1) << endl;
		}
	}
	
	return 0;
}